Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix NaNs for some dbFS value displays (-∞ dbFS) #7142

Merged

Conversation

michaelgregorius
Copy link
Contributor

@michaelgregorius michaelgregorius commented Mar 11, 2024

Fix some NaNs in the context of the display of dbFS values. They occur during the display of the current value when a mixer fader or the volume knob of an instrument is pulled down completely.

The fix is to detect these cases and to display "-∞ dbFS":

MinusInfFader

MinusInfKnob

Also fix a problem with the editor where dbFS values can be entered for volume knobs. When the knob is turned completely to the left and the amplification is 0 then the initially displayed value is set to -96 dBFS, i.e. the lower limit that is shown in the dialog. This is done because the dialog likely cannot handle displaying or entering "-∞".

Fix some NaNs in the context of the display of dbFS values. They occur during the display of the current value when a mixer fader or the volume knob of an instrument is pulled down completely.

The fix is to detect these cases and to display "-∞ dbFS".

Also fix a problem with the editor where dbFS values can be entered for volume knobs. When the knob is turned completely to the left and the amplification is 0 then the initially displayed value is set to -96 dBFS, i.e. the lower limit that is shown in the dialog. This is done because the dialog likely cannot handle displaying or entering "-∞".
@zynskeywolf
Copy link
Contributor

We might want to try consolidating this and #7039 to something consistent and fix the volume slider labels once and for all.

Decrease code repetition even more by applying Veratil's suggestion from a code review.
@sakertooth
Copy link
Contributor

Is this a proper fix? Why would it ever display NaN in the first place?

@michaelgregorius
Copy link
Contributor Author

@sakertooth, it is a proper fix. It displays NaN if you call ampToDbfs with a value <= 0. This happened with the previous code if you pulled the fader all the way down. In that case an amplification of 0 was converted to dbFS which resulted in NaN.

This is fixed with this PR by adding a check and displaying -inf in this case.

@sakertooth
Copy link
Contributor

This is fixed with this PR by adding a check and displaying -inf in this case.

That's odd. For me its already displaying -inf dbFS when I turn the fader/volume knob all the way down.

image

image

@michaelgregorius
Copy link
Contributor Author

Hm, I wonder how it's working then. Does Qt convert the specific NaN to the QString "-inf"?

Anyway, the previous code definitively resulted in NaNs which you can reproduce if you compile with WANT_DEBUG_FPE set to True. log(0) is not defined and therefore the code should take care of it before calling ampToDbfs.

@michaelgregorius
Copy link
Contributor Author

@Veratil, @sakertooth, can I merge this?

@michaelgregorius michaelgregorius merged commit 922eb7f into LMMS:master Apr 5, 2024
9 checks passed
@michaelgregorius michaelgregorius deleted the FixNaNsForDBFSDisplays branch April 5, 2024 11:17
enp2s0 pushed a commit to enp2s0/lmms that referenced this pull request Apr 12, 2024
Fix some NaNs in the context of the display of dbFS values when "View > Volume as dbFS" is checked. They occur during the display of the current value when a mixer fader or the volume knob of an instrument is pulled down completely.

The fix is to detect these cases and to display "-∞ dbFS".

Also fix a problem with the editor where dbFS values can be entered for volume knobs. When the knob is turned completely to the left and the amplification is 0 then the initially displayed value is set to -96 dBFS, i.e. the lower limit that is shown in the dialog. This is done because the dialog likely cannot handle displaying or entering "-∞".
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants